3D Graphics Programming with QuickDraw 3D 1.5.4
Previous | QD3D Book | Overview | Chapter Contents | Next |
A polyhedron is a polyhedral primitive, all of whose faces are triangular. The faces of a polyhedron are defined indirectly, using indices into an array of vertices. This indirection makes it easy for faces to share vertices and attribute sets, thereby reducing the memory required to define the polyhedron and reducing the time required to render the polyhedron. Figure 27 shows a polyhedron.
It's possible to render non-triangular faces by controlling which edges are drawn. For example, you can make a quadrilateral face by defining two triangular faces with a common edge that is not rendered.
You define an individual face of a polyhedron in part by specifying three indexed vertices. An indexed vertex is a three-dimensional vertex specified by its index into an array of three-dimensional points, together with an attribute set. An indexed vertex is defined using the TQ3IndexedVertex3D data type.
typedef struct TQ3IndexedVertex3D {
unsigned long pointIndex;
TQ3AttributeSet attributeSet;
} TQ3IndexedVertex3D;
A polyhedron edge data structure specifies information about an edge of a polyhedron. A polyhedron edge data structure is defined by the TQ3PolyhedronEdgeData data structure.
typedef struct TQ3PolyhedronEdgeData {
unsigned long pointIndices[2];
unsigned long triangleIndices[2];
TQ3AttributeSet edgeAttributeSet;
} TQ3PolyhedronEdgeData;
A polyhedron triangle data structure specifies information about a triangular face of a polyhedron. A polyhedron triangle data structure is defined by the TQ3PolyhedronTriangleData data type.
typedef struct TQ3PolyhedronTriangleData {
TQ3IndexedVertex3D vertices[3];
TQ3PolyhedronEdge edgeFlag;
TQ3AttributeSet triangleAttributeSet;
} TQ3PolyhedronTriangleData;
typedef struct TQ3PolyhedronData {
unsigned long numPoints;
TQ3Point3D *points;
unsigned long numEdges;
TQ3PolyhedronEdgeData *edges;
unsigned long numTriangles;
TQ3PolyhedronTriangleData *triangles;
TQ3AttributeSet polyhedronAttributeSet;
} TQ3PolyhedronData;
Previous | QD3D Book | Overview | Chapter Contents | Next |